package com.xy.tianyu.module.picture.adapter

import android.graphics.Color
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import q.rorbin.verticaltablayout.adapter.TabAdapter
import q.rorbin.verticaltablayout.widget.ITabView

/**
 * @time 2020/10/13 11:00
 * @class 描述:
 */
class PicCategoryPagerAdapter (fm: FragmentManager, var titleList:List<String>, var fragmentList:List<Fragment>) :
    FragmentStatePagerAdapter(fm,
    BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
),TabAdapter{
    override fun getItem(position: Int): Fragment {
        return fragmentList[position]
    }

    override fun getIcon(position: Int): ITabView.TabIcon? {
       return null
    }

    override fun getBadge(position: Int): ITabView.TabBadge? {
        return null
    }

    override fun getBackground(position: Int): Int {
        return 0
    }

    override fun getTitle(position: Int): ITabView.TabTitle {
        return ITabView.TabTitle.Builder()
            .setContent(titleList[position])
            .setTextColor(Color.parseColor("#03DAC5"), Color.BLACK)
            .build()
    }

    override fun getCount(): Int {
       return fragmentList.size
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return titleList[position]
    }

}